package org.giovanolli.mumi.controller.business;

import org.giovanolli.mumi.controller.AbstractController;
import org.giovanolli.mumi.controller.AbstractModel;
import org.giovanolli.mumi.entities.Skill;
import org.giovanolli.mumi.entities.filter.SkillFilter;
import org.giovanolli.mumi.service.Service;
import org.giovanolli.mumi.service.SkillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller("skillController")
public class SkillController extends AbstractController<Skill> {

	@Autowired
	private SkillService service;

	@Autowired
	private SkillModel model;

	@Override
	protected void bindEntityToModel() {
		Skill editedSkill = model.getEditedEntity();
		model.setName(editedSkill.getName());
		model.setDescription(editedSkill.getDescription());
	}

	@Override
	protected void bindModelToEntity() {
		Skill editedSkill = model.getEditedEntity();
		editedSkill.setName(model.getName());
		editedSkill.setDescription(model.getDescription());
	}

	protected Class<Skill> getEntityClass() {
		return Skill.class;
	}

	@Override
	protected AbstractModel<Skill> getModel() {
		return model;

	}

	@Override
	protected Service<Skill> getService() {
		return service;
	}

	public void init() {
		super.init();
		model.setFilter(new SkillFilter());
	}
}
